package edu.sctu.jsoup.service;

import java.io.IOException;
import java.util.Iterator;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import org.springframework.stereotype.Service;

@Service
public class Tour1Service {


    public void run() {
        try {
            Document document = Jsoup.connect("https://www.tripadvisor.cn/Tourism-g294211-China-Vacations.html").get();
            Elements elements = document.select("div.popularCities").first().select("a");

            for (Element element :elements) {
                String sort = element.select("span.rankNum").first().text();
                String name = element.select("span.name").first().text();
                System.out.println(name + "   " + sort);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}